<?php
$database_connection = null;
function get_connection(){
	$hostname = "127.0.0.1"; //数据库服务器主机名,可以用IP代替
	$database = "news"; //数据库名
	$username = "root"; //数据库服务器用户名
	$password = "1314"; //数据库服务器密码
	global $database_connection;
	$database_connection = mysqli_connect($hostname,$username,$password,$database); //连接数据库服务器
	mysqli_query($database_connection,"set names 'utf8'");//设置字符集
	mysqli_select_db($database_connection,$database) or die(mysqli_error());
	return  $database_connection;
}

function close_connection()
{
	global $database_connection;
	if($database_connection)
	{
		mysqli_close($database_connection) or die(mysqli_error());
	}
}
?>
